package com.evangelion.core.pojo;

import javax.persistence.Column;
import javax.persistence.ColumnResult;
import javax.persistence.ConstructorResult;
import javax.persistence.Entity;
import javax.persistence.EntityResult;
import javax.persistence.FieldResult;
import javax.persistence.Id;
import javax.persistence.SqlResultSetMapping;
import javax.persistence.SqlResultSetMappings;


/**
 * Date: 4/8/2014
 */
@Entity
@SqlResultSetMappings({
@SqlResultSetMapping(name = "AlumnoClassContractedMapping",
        entities = {@EntityResult(entityClass = AlumnoClassPractica.class,
                fields = {
                        @FieldResult(name = "alumnoId", column = "id_columno"),
                        @FieldResult(name = "nombres", column = "nombres"),
                        @FieldResult(name = "apellidos", column = "apellidos"),
                        @FieldResult(name = "contracted", column = "ccount")})})
, @SqlResultSetMapping(
        name = "AlumnoClassConsumedMapping",
        classes = {@ConstructorResult(
                targetClass = AlumnoClassPractica.class,
                columns = {
                        @ColumnResult(name = "id_columno"),
                        @ColumnResult(name = "nombres"),
                        @ColumnResult(name = "apellidos"),
                        @ColumnResult(name = "ccount")})})
})
public class AlumnoClassPractica {

    public AlumnoClassPractica() {
    }


    public AlumnoClassPractica(Number alumnoId, String nombres, String apellidos, Number consumed) {
        if (null != alumnoId) {
            this.alumnoId = alumnoId.intValue();
        }
        this.nombres = nombres;
        this.apellidos = apellidos;
        if (null != consumed) {
            this.consumed = consumed.intValue();
        }
    }


    @Id
    private Integer alumnoId;

    @Column
    private String nombres;

    @Column
    private String apellidos;

    @Column
    private Integer contracted = 0;

    @Column
    private Integer consumed = 0;


    public Integer getConsumed() {
        return consumed;
    }


    public void setConsumed(Integer consumed) {
        this.consumed = consumed;
    }


    public Integer getAlumnoId() {
        return alumnoId;
    }


    public void setAlumnoId(Integer id) {
        this.alumnoId = id;
    }


    public String getNombres() {
        return nombres;
    }


    public void setNombres(String nombres) {
        this.nombres = nombres;
    }


    public String getApellidos() {
        return apellidos;
    }


    public void setApellidos(String apellidos) {
        this.apellidos = apellidos;
    }


    public Integer getContracted() {
        return contracted;
    }


    public void setContracted(Integer count) {
        this.contracted = count;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        AlumnoClassPractica that = (AlumnoClassPractica) o;

        if (!alumnoId.equals(that.alumnoId)) {
            return false;
        }

        return true;
    }


    @Override
    public int hashCode() {
        return alumnoId.hashCode();
    }
}
